using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Castle.ActiveRecord;
using Castle.ActiveRecord.Queries;


#region 'test' Schema
/*
 * 'Test' class maps to 'test' table.
 * 	 userid                  | Type:numeric   | Len:0     | Nullable:F | PK:T | FK:F
 * 	 loginid                 | Type:varchar   | Len:25    | Nullable:T | PK:F | FK:F
 * 	 username                | Type:varchar   | Len:20    | Nullable:T | PK:F | FK:F
 */
#endregion
/// <summary>
///	Generated by MyGeneration using the ActiveRecord Object Mapper - 1.0.2
///	Created on 2011/8/16 20:46:49
/// </summary>
namespace Com.GainWinSoft.ERP.Entity
{
	[Serializable , ActiveRecord("TEST2")]
	public class Test2 : ActiveRecordBase	{

		#region Private Members

        //private int userid; 
        //private string loginid; 
		private string username;
        private UserKey id;
		
		#endregion

		#region Constuctor(s)
		
		public Test2()
		{
            id = new UserKey();
			id.Userid = 0; 
			id.Loginid = String.Empty; 
			username = String.Empty; 
            
		}

		public Test2(
			int uid,String lid)
			: this()
		{
            id = new UserKey();
            id.Userid = uid;
            id.Loginid =lid;

			username = String.Empty;
		}

		#endregion // End of Class Constuctor(s)
		
		#region Public Properties
        [CompositeKey]
        public virtual UserKey Id
        {
            get { return id; }
            set { id = value; }
        }
		
        //public virtual int Userid
        //{
        //    get { userid = this.id.Userid; return this.id.Userid; }
        //    set { this.id.Userid = value; userid = value; }
        //}

		
        //public virtual string Loginid
        //{
        //    get { loginid = this.id.Loginid; return this.id.Loginid; }
        //    set { this.id.Loginid = value; loginid = value; }
        //}

		[Property(Column="USERNAME", Length=100)]
		public virtual string Username
		{
			get { return username; }
			set { username = value; }
		}


		#endregion 


			
		#region Equals, HashCode and ToString overrides
		
		/// <summary>
		/// Local implementation of Equals based on unique value members
		/// </summary>
		public override bool Equals( object obj )
		{
			if( this == obj ) return true;
			if( ( obj == null ) || ( obj.GetType() != this.GetType() ) ) return false;
			Test2 castObj = (Test2)obj; 
			return ( castObj != null ) &&
				( this.id.Userid == castObj.id.Userid )&&(this.id.Loginid==castObj.id.Loginid);
		}
		
		/// <summary>
		/// Local implementation of GetHashCode based on unique value members
		/// </summary>
		public override int GetHashCode()
		{
			
			int hash = 57; 
			hash = 27 * hash * this.id.Userid.GetHashCode();
            hash = 27 * hash * this.id.Loginid.GetHashCode();
            return hash; 
		}
		
		/// <summary>
		/// Local implementation of ToString based on class members
		/// </summary>
		public override String ToString()
        {
            StringBuilder sbuffer = new StringBuilder();
			sbuffer.Append("{");
			
			sbuffer.AppendFormat("Userid = {0}, ",this.id.Userid);
			sbuffer.AppendFormat("Loginid = {0}, ",this.id.Loginid);
			sbuffer.AppendFormat("Username = {0}, ",username);
			sbuffer.Append(" }");
			return sbuffer.ToString();
        }
		
		#endregion

	}
    [Serializable]
    public class UserKey
    {
        private int userid;
        private string loginid;
        [KeyProperty(Column="USERID")]
        public virtual int Userid
        {
            get { return userid; }
            set { userid = value; }
        }


        [KeyProperty(Column = "LOGINID")]
        public virtual string Loginid
        {
            get { return loginid; }
            set { loginid = value; }
        }

        public override int GetHashCode()
        {
            int hash = 57;
            hash = 27 * hash * userid.GetHashCode();
            hash = 27 * hash * loginid.GetHashCode();
            return hash;
        }

        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return true;
            }
            UserKey key = obj as UserKey;
            if (key == null)
            {
                return false;
            }
            if (userid != key.userid || loginid != key.loginid)
            {
                return false;
            }
            return true;
        }

    }

}
